/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package descifrado;

/**
 *
 * @author juli
 */
public class Descifrado extends BaseDescifrado{

     public Descifrado(boolean[][] C, boolean[][] M, boolean[][] Y, boolean[][] K) {
        super(C, M, Y, K);
    }
    
    @Override
    protected int[][] superimpose(boolean[][] C, boolean[][] M, boolean[][] Y, boolean[][] K) {

        int [][] result= new int [C.length][C[0].length];

        for(int i=0;i<C.length;i++){
            for(int j = 0; j<C[0].length;j++){
                int sum = 0;

                if(C[i][j]==true)
                    sum+=4;
                if(M[i][j]==true)
                    sum+=2;
                if(Y[i][j]==true)
                    sum+=1;

                /*
				 * CONVERSION TABLE
				 *
				 * C=4		M=2		Y=1
				 *
				 * 		C	M	Y
				 * 0					= 0
				 * 1	X				= 4
				 * 2		X			= 2
				 * 3			X		= 1
				 * 4	X	X			= 6
				 * 5		X	X		= 3
				 * 6	X		X		= 5
				 * 7	X	X	X		= 7 negro
				 *
				 *
				 * difungir
				 */

                switch(sum){
                    case 0: result[i][j]=0;
                            break;
                    case 1: result[i][j]=3;
                            break;
                    case 2: result[i][j]=2;
                            break;
                    case 3: result[i][j]=5;
                            break;
                    case 4: result[i][j]=1;
                            break;
                    case 5: result[i][j]=6;
                            break;
                    case 6: result[i][j]=4;
                            break;
                    case 7: result[i][j]=7;
                            break;
                }

                if(K[i][j]==true)
                    result[i][j]=7;
            }
        }

        return result;
    }



}
